import 'package:example/pages/http_request_page.dart';
import 'package:lib_common/lib_common.dart';
import 'package:lib_http/http/http_manager.dart';
import 'package:lib_http/http/log_interceptor.dart';

void main() {
  HttpManager.getInstance().init("http://www.baidu.com",
      interceptors: [LogInterceptor(requestBody: true, responseBody: true, logPrint: (msg) => LogUtils.v(msg, tag: "HttpRequest"))]);
  runApp(const HttpRequest());
}

class HttpRequest extends StatelessWidget {
  const HttpRequest({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        debugShowCheckedModeBanner: false,
        title: 'HttpRequest',
        theme: ThemeData(primarySwatch: Colors.blue),
        home: const HttpRequestPage(),
        builder: (context, child) {
          return FlutterSmartDialog(child: child);
        });
  }
}

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(title: const Text("Http Request")),
        floatingActionButton: FloatingActionButton(onPressed: request, tooltip: 'Request', child: const Icon(Icons.send)));
  }

  void request() {}
}
